#!/bin/bash

wd="`pwd`"
. $wd/env

echo ""
echo " This script will copy all packages that appear listed in:  "
echo " 		./files/installcd-initrd/nemonico/files/packages/pkglist/default "
echo ""
if [ ! "$sets_location" ]; then
	echo " Enter path to where the original slackware sets"
	echo -n " 	 are located: "
	read sets_location
fi

if [ ! -d $sets_location ]; then
	echo " It does not exist or is not a directory, exiting..."
	exit 1
fi
	
if [ -d $wd/files/installcd-initrd/nemonico/files/packages/pkglist/default ]; then

	mkdir -p $wd/cdtree/slackware
	t="$wd/files/installcd-initrd/nemonico/files/packages/pkglist/default"
	cd $wd/cdtree/slackware
	for f in `ls $t`; do
		echo "$f ..."
		for p in `cat $t/$f`;do
			mkdir -p `dirname $p`
			# match exclude
			for e in $exclude_slk_pkg ; do
				[ "`echo $p|grep $e`" ] && \
				{ echo "Excluding: $p, continuing ...";
				continue; }
			done
			cp -rf ${sets_location}/$p `dirname $p`
		done
	done

	cd $wd
	echo " Done. "
fi
